/*************************************************
 * 描述：表格基础模型
 *
 * File：cxitablemodel.h
 * Author：zhangzhiming@mozihealthcare.cn
 * Date：25-10-16
 * Update：
 * ************************************************/
#ifndef CXITABLEMODEL_H
#define CXITABLEMODEL_H

#include <controls/table/head.h>
#include <controls/export.h>
#include <QAbstractTableModel>

class CXI_CONTROLS_EXPORT CxiTableModel : public QAbstractTableModel
{
	Q_OBJECT
public:
	explicit CxiTableModel(QObject* parent = nullptr);

	void setColumnConfig(const QList<cxitable::GridColumnConfig>& configs);

	~CxiTableModel();

	bool setData(const QModelIndex& index, const QVariant& value, int role) override;

	QVariant data(const QModelIndex& index, int role) const override;

	int columnCount(const QModelIndex& parent = QModelIndex{}) const override;

	Qt::ItemFlags flags(const QModelIndex &index) const override;
protected:
	virtual bool setFieldData(
			const QModelIndex& index,
			int role,
			const QString& field,
			const QVariant& data) = 0;

	virtual QVariant fieldData(
			const QModelIndex& index,
			int role,
			const QString& field) const = 0;

	QList<cxitable::GridColumnConfig> d_columns;
};


#endif//CXITABLEMODEL_H
